<template>
  <div class="tiaoxuan_left">
    <ul>
      <li v-for="item in lis" :key="item.id" @click="toright(item)">
        <router-link :to="'/tiaoxuanchexing/' + item.id">
          <p>{{ item.typeName }}</p>
          <p>{{ item.startPrice }}元起</p>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
// 引入请求
import { select, right } from "../../../request/select_car/select_car";
export default {
  props: {},
  data() {
    return {
      lis: [],
      shopId:0,
      item1:{
        id:'2',
      }
    };
  },
  mounted() {
    this.$store.state.list_r = []
    // 查询所有车辆类型
    // select().then((res) => {
    //   this.lis = res;
    //   this.$router.push("/tiaoxuanchexing/1");
    // });
    select({
      data: {},
    }).then((res) => {
      console.log("左边请求------------")
      console.log(res)
      //if(res.code==200){
      this.lis = res.data;
      this.$router.push("/tiaoxuanchexing/1");
    });

    // 查询所有车辆
    right({
      // type: 1, // 车辆类型
      // shopId: this.$store.state.brrowShop, // 门店id
      "shopId": this.$store.state.shopId,
      "type": 1,
      "startTime": this.$store.state.startime,
      "endTime": this.$store.state.endtime
    }).then((res) => {
      this.$store.state.list_r = res;
    });
  },
  created() {
    this.getCarType()
    this.toright(this.item1);
  },
  methods: {
    getCarType(){
      this.$http.get("http://192.168.1.195:8000/rent/cartype/getCarType").then(res=>{
        console.log(res.data)
        this.lis=res.data.data;
      })
    },
    oyr(){
      if (this.$store.state.oby>0){
        this.a=this.$store.state.oby
      }
    },
    toright(item) {
      this.$root.type=item.id
      console.log(item)
      console.log(this.$root.type)
      console.log(this.$store.state.brrowShop)
      if (this.$store.state.oby>0){
        this.or=this.$store.state.oby
      }
      this.shopId=this.$store.state.brrowShop
      right({
        "shopId": this.$store.state.brrowShop,
        // type: item.id,
        // "selectId": this.$store.state.condition,
        "type": item.id,
        "or":this.or,
        // "startTime": this.$store.state.startime,
        // "endTime": this.$store.state.endtime
      }).then((res) => {
        console.log(res)
        this.$store.state.list_r = res;
      });
      this.$emit("left", item.url);
    },
  },
  components: {},
};
</script>

<style scoped lang="less">
.tiaoxuan_left {
  width: 1.49rem;
  height: 100%;
  ul {
    width: 100%;
    display: flex;
    flex-direction: column;
    margin-top: -0.1rem;
    .activing {
      background: white;
      div {
        border-left: 0.05rem solid #4b7ce2;
      }
    }
    li {
      width: 100%;
      height: 1.14rem;
      margin: 0.1rem 0;
      display: flex;
      align-items: center;
      .router-link-active {
        background-color: #fff;
        border-left: 0.05rem solid #4b7ce2;
      }
      a {
        width: 100%;
        height: 100%;
        padding-left: 0.23rem;
        box-sizing: border-box;
        p:first-child {
          width: 100%;
          font-size: 0.23rem;
          font-weight: 600;
        }
        p:last-child {
          font-size: 0.17rem;
          font-weight: 600;
          color: #999999;
        }
      }
    }
  }
}
</style>
